package com.leyou.sh.item.client;

import com.leyou.sh.common.dto.PageDTO;
import com.leyou.sh.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author balisong_fcs
 * @date 2021/1/5 19:13
 * @desc
 */
@FeignClient("item-service")
public interface ItemClient {
    /**
     * 分页查询数据
     * @param brandId
     * @param categoryId
     * @param id
     * @param page
     * @param rows
     * @param saleable
     * @return
     */
    @GetMapping("/goods/spu/page")
    PageDTO<SpuDTO> querySpuByPage(
            @RequestParam(value = "brandId", required = false) Integer brandId,
            @RequestParam(value = "categoryId", required = false) Integer categoryId,
            @RequestParam(value = "id", required = false) Integer id,
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "saleable", required = false) Boolean saleable
    );

    @GetMapping("/brand/{id}")
    BrandDTO queryBrandById(@PathVariable("id") Long id);

    @GetMapping("/category/{id}")
    CategoryDTO queryCategoryById(@PathVariable("id") Long id);

    /**
     * 根据spuid查询sku集合
     *
     * @param id
     * @return
     */
    @GetMapping("/goods/sku/of/spu")
     List<SkuDTO> querySkuBySpuId(@RequestParam("id") Long id);

    /**
     * 根据spuid查询spu的所有规格参数值
     * @param id
     * @param searching
     * @return
     */
    @GetMapping("/goods/spec/value")
    List<SpecParamDTO> querySpecParamValue(
            @RequestParam("id") Long id,
            @RequestParam(value = "searching", required = false) Boolean searching
    );
    /**
     * 根据spuId查询spu
     * @param spid
     * @return
     */
    @GetMapping("/goods/spu/{id}")
     SpuDTO querySpuById(@PathVariable("id") Long spid);

    /**
     * 根据spuid 查询spudetail信息
     * 一对一
     *
     * @param id
     * @return
     */
    @GetMapping("/goods/spu/detail")
    SpuDetailDTO querySpuDetailBySpuid(@RequestParam("id") Long id);

    /**
     * 根据分类ids查询分类集合
     *
     * @param ids
     * @return
     */
    @GetMapping("/category/list")
    List<CategoryDTO> queryCategoryByIds(@RequestParam("ids") List<Long> ids);

    /**
     * 根据分类id查询规格组及其组内参数
     * 这里的方法没有设置对应的value值
     *
     * @param id
     * @return
     */
    @GetMapping("/spec/list")
    List<SpecGroupDTO> querySpecGroupAndSpecParamByCategory(@RequestParam("id") Long id);

    /**
     * 根据id集合查询品牌集合
     *
     * @param ids
     * @return
     */
    @GetMapping("/brand/list")
    List<BrandDTO> queryBrandByIds(@RequestParam("ids") List<Long> ids);//标记一下id数据类型修改

    /**
     * 根据Skuids 查询sku集合
     *
     * @param ids
     * @return
     */
    @GetMapping("/goods/sku/list")
    List<SkuDTO> querySkuByIds(@RequestParam("ids") List<Long> ids);

    /**
     * 减库存
     * @param cartMap 商品id及数量的map
     */
    @PutMapping("/goods/stock/minus")
    Void deductStock(@RequestBody Map<Long,Integer> cartMap);
}
